import java.io.*;

public class Exercise {
    public static void main(String[] args) throws IOException {
        // 1.
        // 使用字节输入流读取图片的二进制数据

        // 2.
        // 使用字节输出流将以下内容写入到1个文件
      //  byte[] buf= {97,98,99,100};


        // * 3.
        // 编写一个copy(String srcPath,String destPath)实现复制文件
//		copy("e:/1.mp4","e:/2.mp4")


        InputStream in = new FileInputStream("e:/03chenhaisheng/1.jpeg");

        int len=0;
        byte[] buf = new byte[1024];

        while((len=in.read(buf))!=-1)
        {
            System.out.println("读到长度:"+len);
        }




        // 1. 打开流
        OutputStream out = new FileOutputStream("e:/03chenhaisheng/1.txt");
        // 2. 写入数据
        byte[] buf2= {97,98,99,100};
        out.write(buf2);
        // 3. 关闭流
        out.close();

        copy("e:/03chenhaisheng/1.jpeg","e:/03chenhaisheng/2.jpeg");

    }

    public static void copy(String srcPath,String destPath) throws IOException {

        InputStream in = new BufferedInputStream( new FileInputStream(srcPath));
        OutputStream out = new BufferedOutputStream( new FileOutputStream(destPath));
        int len=0;
        byte[] buf = new byte[1024];

        while((len=in.read(buf))!=-1)

        {
            System.out.println(in.read());
            out.write(buf,0,len);
        }
        in.close();
        out.close();


    }
}
